Cross-Validation


In [ ]:
from sklearn.datasets import load_digits

In [ ]:
digits = load_digits()
X = digits.data
y = digits.target

In [ ]:
from sklearn.cross_validation import cross_val_score
from sklearn.svm import LinearSVC

In [ ]:
cross_val_score(LinearSVC(), X, y, cv=5)

In [ ]:
cross_val_score(LinearSVC(), X, y, cv=5, scoring="f1_macro")

In [ ]:
from sklearn.metrics.scorer import SCORERS
print(SCORERS.keys())

There are other ways to do cross-valiation


In [ ]:
from sklearn.cross_validation import ShuffleSplit

shuffle_split = ShuffleSplit(len(X), 10, test_size=.4)
cross_val_score(LinearSVC(), X, y, cv=shuffle_split)